/*    */ package handling.login.handler;
/*    */ 
/*    */ import client.MapleCharacter;
/*    */ import client.MapleClient;
/*    */ import client.MaplePartTimeJob;
/*    */ import tools.data.input.LittleEndianAccessor;
/*    */ import tools.packet.LoginPacket;
/*    */ 
/*    */ public class PartJobHandler
/*    */ {
/*    */   public static void handlePacket(LittleEndianAccessor slea, MapleClient c) {
/* 12 */     if (!c.isLoggedIn()) {
/* 13 */       c.getSession().close();
/*    */       return;
/*    */     } 
/* 16 */     byte mode = slea.readByte();
/* 17 */     int cid = slea.readInt();
/* 18 */     byte job = slea.readByte();
/* 19 */     if (mode == 1) {
/* 20 */       MaplePartTimeJob partTime = MapleCharacter.getPartTime(cid);
/* 21 */       if (job < 0 || job > 5 || partTime.getReward() > 0 || (partTime.getJob() > 0 && partTime.getJob() <= 5)) {
/* 22 */         c.getSession().close();
/*    */         return;
/*    */       } 
/* 25 */       long time = System.currentTimeMillis();
/* 26 */       partTime.setTime(time);
/* 27 */       partTime.setJob(job);
/* 28 */       MapleCharacter.removePartTime(cid);
/* 29 */       MapleCharacter.addPartTime(partTime);
/* 30 */       c.announce(LoginPacket.updatePartTimeJob(partTime));
/* 31 */     } else if (mode == 2) {
/* 32 */       MaplePartTimeJob partTime = MapleCharacter.getPartTime(cid);
/* 33 */       if (partTime.getReward() > 0 || partTime.getJob() < 0 || partTime.getJob() > 5) {
/* 34 */         c.getSession().close();
/*    */         return;
/*    */       } 
/* 37 */       long distance = (System.currentTimeMillis() - partTime.getTime()) / 3600000L;
/* 38 */       if (distance > 1L) {
/* 39 */         partTime.setReward((int)((partTime.getJob() + 1) * 1000L + distance));
/*    */       } else {
/* 41 */         partTime.setJob((byte)0);
/* 42 */         partTime.setReward(0);
/*    */       } 
/* 44 */       partTime.setTime(System.currentTimeMillis());
/* 45 */       MapleCharacter.removePartTime(cid);
/* 46 */       MapleCharacter.addPartTime(partTime);
/* 47 */       c.announce(LoginPacket.updatePartTimeJob(partTime));
/*    */     } 
/*    */   }
/*    */ }


/* Location:              C:\PGX\Server.jar!\handling\login\handler\PartJobHandler.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */